#ifndef _DAG_LOOOP_ANALYZER_H_
#define _DAG_LOOOP_ANALYZER_H_

#include "dag.h"
#include <list>
#include <map>
#include <set>

namespace dag {
	class DAG_LOCAL Vertex {
	public:
		const Node* node;
		int index;
		int lowIndex;
		
		Vertex();
		Vertex(const Node* a_node);
		bool hasBeenIndexed() const;
		bool operator==(const Vertex& rhs) const;
		bool operator<(const Vertex& rhs) const;
	};

	
	class DAG_LOCAL LoopAnalyzer {
	public:
		LoopAnalyzer();
		virtual ~LoopAnalyzer();
		void findLoops(const Graph& graph, std::list<std::set<const Node*> >& loops);
		
	private:
		void reset();
		std::set<const Node*> strongConnection(Vertex& vertex,
										 std::list<std::set<const Node*> >& loops);
		std::map<const Node*, Vertex> m_Visited;
		std::list<Vertex*> m_Stack;
		int m_Index;
		const Graph* m_Graph;
	};
}

#endif

